{#

This file is part of the Sonata package.

(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.

#}

{% extends base_template %}

{% block actions %}
    <li>{% include 'SonataAdminBundle:Button:edit_button.html.twig' %}</li>
    <li>{% include 'SonataAdminBundle:Button:history_button.html.twig' %}</li>
    <li>{% include 'SonataAdminBundle:Button:show_button.html.twig' %}</li>
    <li>{% include 'SonataAdminBundle:Button:list_button.html.twig' %}</li>
{% endblock %}

{% block form %}
    <form class="form-horizontal"
              action="{{ admin.generateUrl('acl', {'id': admin.id(object), 'uniqid': admin.uniqid, 'subclass': app.request.get('subclass')}) }}" {{ form_enctype(form) }}
              method="POST"
              {% if not admin_pool.getOption('html5_validate') %}novalidate="novalidate"{% endif %}
              >
        {% if form.vars.errors|length > 0 %}
            <div class="sonata-ba-form-error">
                {{ form_errors(form) }}
            </div>
        {% endif %}

        <table class="table">
            <thead>
                <tr>
                    <th>{{ "td_username"|trans({}, 'SonataAdminBundle') }}</th>
                    {% for permission in permissions %}
                    <th>{{ permission }}</th>
                    {% endfor %}
                </tr>
            </thead>
            <tbody>
            {% for user in users %}
                <tr>
                    <td>{{ user }}</td>
                    {% for permission in permissions %}
                    <td>{{ form_widget(form[user.id ~ permission]) }}</td>
                    {% endfor %}
                </tr>
            {% endfor %}
            </tbody>
        </table>

        {{ form_rest(form) }}

        {% block formactions %}
            <div class="well well-small form-actions">
                <input class="btn btn-primary" type="submit" name="btn_create_and_edit" value="{{ 'btn_update_acl'|trans({}, 'SonataAdminBundle') }}">
            </div>
        {% endblock formactions %}
    </form>
{% endblock %}
